<template>
	<view class="content" :style="app_bg">
		<view class="topTitle" :style="'top:'+zhuangtai+'px'">
			<image class="back" @click="backClick" :src="publicimg.btn_back" mode=""></image>
			<view class="" style="font-size: 32rpx;">
				分销中心
			</view>
		</view>
		<view class="my-info" :style="user_margin_top">
			<view class="user-info">
				<image class="avatar" :src="avatar" mode=""></image>
				<view class="user-text-info">
					<text class="font30" :style="font_1st">{{nickname}}</text>
					<view class="lv-center">
						<image class="lv-icon" :src="level_icon" mode=""></image>
						<text class="font28 fontw" :style="font_1st">Lv.{{level_name}}</text>
					</view>
				</view>
			</view>
			<view class="btn-list">
				<button open-type="share" type="default" class="left-btn" style="margin-right: 30upx;">
					<image class="bgimgpublic" style="z-index: 0;" :src="publicimg.btn_xs_warm" mode=""></image>
					<text class="font30" style="z-index: 1;" :style="font_1st">邀请好友</text>
				</button>
				<view class="left-btn" @click="goToPoster">
					<image class="bgimgpublic" style="z-index: 0;" :src="publicimg.btn_xs_warm" mode=""></image>
					<text class="font30" style="z-index: 1;" :style="font_1st">海报邀请</text>
				</view>
			</view>
		</view>
		<view class="friend-info" :style="app_theme">
			<view class="top-text-list" :style="app_border_bottom">
				<text class="font34 fontw500" :style="font_1st">今日好友总贡献量</text>
				<text class="font30" @click="$refs.disRule.open()" :style="font_3rd">玩法说明</text>
			</view>
			<view class="prize-list font28" :style="font_1st">
				<view class="item">
					<image :src="appConfig.exp_icon" mode=""></image>
					<text>{{today_exp}}{{appConfig.exp_name}}</text>
				</view>
				<view class="item">
					<image :src="appConfig.game_coin_icon" mode=""></image>
					<text>{{today_game_coin}}{{appConfig.game_coin_name}}</text>
				</view>
				<view class="item">
					<image :src="appConfig.gold_coin_icon" mode=""></image>
					<text>{{today_gold_coin}}{{appConfig.gold_coin_name}}</text>
				</view>
				<view class="item">
					<image :src="appConfig.money_icon" mode=""></image>
					<text>{{today_money}}{{appConfig.money_name}}</text>
				</view>
			</view>
		</view>
		<view class="my-time" :style="app_theme" @click="goToDisFriend">
			<view class="left">
				<image src="../../static/time.png" mode=""></image>
				<text class="font34" :style="font_1st">我的团队</text>
			</view>
			<image class="next-icon" :src="publicimg.btn_next" mode=""></image>
		</view>
		<view class="my-time" @click="goToProfitIndex" :style="app_theme">
			<view class="left">
				<image src="../../static/time.png" mode=""></image>
				<text class="font34" :style="font_1st">贡献收益</text>
			</view>
			<image class="next-icon" :src="publicimg.btn_next" mode=""></image>
		</view>
		<uni-popup ref="disRule" type="center" :maskClick="false">
			<view class="loadexchagepopup" :style="app_theme">
				<view class="exchagetop" :style="'background:'+publicTextColor.app_border_color+';'">
					<image @click="$refs.disRule.close()" class="closepopup" :src="publicimg.btn_close" mode=""></image>
					<text class="font36 index-1" style="margin-top: 28rpx;" :style="font_1st">提示</text>
				</view>
				<scroll-view scroll-y="true" style="height: 300rpx;">
					<view class="rule-text" :style="font_3rd">
						<rich-text :nodes="desc"></rich-text>
					</view>
				</scroll-view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	var util = require('@/js/util.js')
	export default {
		data() {
			return {
				publicTextColor:'',
				publicimg:'',
				zhuangtai:0,
				appConfig:'',
				nickname:'',
				avatar:'',
				today_gold_coin:0,
				today_game_coin:0,
				today_exp:0,
				today_money:0,
				desc:'',
				level_name:'',
				level_icon:''
			};
		},
		onShow() {
			let that = this
			let aniosgaodu = 0
			uni.getSystemInfo({
				success: function(res) {
					console.log(res);
					that.zhuangtai = res.statusBarHeight;
					var a = res.model.split(' ');
					if (a[0] == 'iPhone') {
						aniosgaodu = 44;
					} else {
						aniosgaodu = 48;
					}
					that.zhuangtai = parseInt(that.zhuangtai)+4
					console.log(that.zhuangtai)
				}
			});
		},
		onLoad() {
			this.setcolorConfig()
			this.getSignIndex()
		},
		onShareAppMessage() { // 分享 buttom share
			return {
				title: '合成王者',
				path: '/pages/index/index?parent_id='+uni.getStorageSync('member_id')
			}
		},
		computed:{
			user_margin_top(){
				return `margin-top:${(this.zhuangtai+52)}px;background:${this.publicTextColor.app_theme_color};`
			},
			page_top(){
				return `margin-top:${(this.zhuangtai+52)}px;`
			},
			app_border_top(){
				return `border-top:2rpx solid ${this.publicTextColor.app_border_color};`
			},
			app_border_bottom(){
				return `border-bottom:2rpx solid ${this.publicTextColor.app_border_color};`
			},
			app_border(){
				return `border:2rpx solid ${this.publicTextColor.app_border_color};`
			},
			app_theme(){
				return `background:${this.publicTextColor.app_theme_color};`
			},
			app_bg(){
				return `background:${this.publicTextColor.app_bg_color};`
			},
			font_4th(){
				return `color:${this.publicTextColor.font_4th_color};`
			},
			font_3rd(){
				return `color:${this.publicTextColor.font_3rd_color};`
			},
			font_2nd(){
				return `color:${this.publicTextColor.font_2nd_color};`
			},
			font_1st(){
				return `color:${this.publicTextColor.font_1st_color};`
			}
		},
		methods:{
			goToPoster(){
				uni.navigateTo({
					url:'posterImage'
				})
			},
			goToProfitIndex(){
				uni.navigateTo({
					url:'profitIndex'
				})
			},
			goToDisFriend(){
				uni.navigateTo({
					url:'distributionFriends'
				})
			},
			getSignIndex(){
				let _self = this
				uni.request({
					url: util.getUrl("distribution/index"),
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation':uni.getStorageSync("token")
					},
					data:{
					},
					method: 'POST',
					success: res => {
						if(res.data.code == 1){
							_self.nickname = res.data.data.nickname
							_self.avatar = res.data.data.avatar
							_self.today_gold_coin = res.data.data.today_gold_coin
							_self.today_game_coin = res.data.data.today_game_coin
							_self.today_exp = res.data.data.today_exp
							_self.today_money = res.data.data.today_money
							_self.desc = res.data.data.desc
							_self.level_name = res.data.data.level_name
							_self.level_icon = res.data.data.level_icon
						}
					},
				});
			},
			setcolorConfig(){
				this.publicTextColor = uni.getStorageSync("diyColor")
				this.publicimg = uni.getStorageSync("diyImg")
				this.appConfig = uni.getStorageSync("appconfig")
			},
			backClick(){
				uni.navigateBack({
					
				})
			}
		}
	}
</script>

<style lang="scss">
	.loadexchagepopup{
		display: flex;
		align-items: center;
		flex-direction: column;
		padding-bottom: 40rpx;
		border-radius: 15rpx;
		position: relative;
		width: 690rpx;
		.rule-text{
			width: 633upx;
			line-height: 48upx;
			box-sizing: border-box;
			padding: 0 30upx;
		}
		.textrule{
			box-sizing: border-box;
			padding: 3rpx 56rpx 46rpx 51rpx;
			height: 500rpx;
		}
		.text1{
			text-align: center;
			line-height:45rpx;
		}
		.btnlist{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 45rpx;
			.btn{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 200rpx;
				height: 60rpx;
				position: relative;
			}
		}
		.centerimage{
			width: 265rpx;
			height: 247rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 43rpx;
			position: relative;
			.exchangegoodsimage{
				width: 127rpx;
				height: 169rpx;
				background-color: #FFFFFF;
				z-index: 1;
			}
		}
		.exchagetop{
			position: relative;
			width: 690rpx;
			height: 80rpx;
			display: flex;
			justify-content: center;
			border-radius: 15rpx 15rpx 0 0;
			margin-bottom: 43rpx;
			.closepopup{
				position: absolute;
				right: 30rpx;
				top:30rpx;
				height: 31rpx;
				width: 31rpx;
			}
			.imagetop{
				position: absolute;
				top: 0;
				z-index: 0;
				height: 92rpx;
				width: 445rpx;
			}
		}
	}
	.my-time{
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 690upx;
		border-radius: 20upx;
		margin-bottom: 30upx;
		padding: 27upx 30upx 27upx 26upx;
		.left{
			display: flex;
			align-items: center;
			image{
				width: 56upx;
				height: 46upx;
			}
		}
		.next-icon{
			width: 20upx;
			height: 31upx;
		}
	}
	.friend-info{
		display: flex;
		flex-direction: column;
		width: 690upx;
		padding: 24upx 0 33upx 0;
		box-sizing: border-box;
		border-radius: 20upx;
		margin-bottom: 30upx;
		.prize-list{
			display: flex;
			align-items: center;
			justify-content: space-around;
			margin-top: 32upx;
			.item{
				display: flex;
				align-items: center;
				flex-direction: column;
				image{
					width: 80upx;
					height: 80upx;
					margin-bottom: 20upx;
				}
			}
		}
		.top-text-list{
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			padding: 0 34upx;
			box-sizing: border-box;
			padding-bottom: 25upx;
			
		}
	}
	.my-info{
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 690upx;
		border-radius: 20upx;
		box-sizing: border-box;
		padding: 32upx 31upx;
		margin-bottom: 30upx;
		.btn-list{
			display: flex;
			align-items: center;
			.left-btn{
				width: 150upx;
				height: 48upx;
				display: flex;
				align-items: center;
				justify-content: center;
				position: relative;
				background-color: rgba(0,0,0,0);
				padding: 0;
				&::after{
					border: none;
					background: none;
				}
			}
		}
		.user-info{
			display: flex;
			align-items: center;
			.avatar{
				width: 90upx;
				height: 90upx;
				margin-right: 32upx;
			}
			.user-text-info{
				display: flex;
				flex-direction: column;
				.lv-center{
					display: flex;
					align-items: center;
					margin-top: 15upx;
					.lv-icon{
						width: 30upx;
						height: 30upx;
						margin-right: 10upx;
					}
				}
			}
		}
	}
	.content{
		min-height: 100vh;
		width: 750rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		box-sizing: border-box;
	}
	.topTitle{
		color: #FFFFFF;
		display: flex;
		align-items: center;
		height: 67rpx;
		justify-content: center;
		position: absolute;
		z-index: 10;
		width: 100%;
		.back{
			width: 20rpx;
			height: 31rpx;
			position: absolute;
			left: 31rpx;
		}
	}
</style>
